from django.contrib.auth.models import User, Group
from rest_framework import serializers
from drfUser.models import UserInfo, Loginlogs, TouTiao, Witticism


class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = UserInfo
        # 展示全部字段
        fields = ['id', 'username', 'email', 'phone', 'gender', 'occupation', 'Remarks','avatar']


class GroupSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Group
        fields = ['id', 'name']


class LoginLogSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Loginlogs
        fields = ['id', 'username', 'ip', 'login_time']


class TouTiaoSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = TouTiao
        fields = "__all__"


class WitticismSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Witticism
        fields = "__all__"
